package com.code9xs.mapper;

import com.code9xs.pojo.LikeAndFavorites;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface LikeAndFavoritesMapper {
    int deleteByPrimaryKey(@Param("uid") Integer uid, @Param("articleId") Integer articleId);

    int insert(LikeAndFavorites record);

    int insertSelective(LikeAndFavorites record);

    LikeAndFavorites selectByPrimaryKey(@Param("uid") Integer uid, @Param("articleId") Integer articleId);

    int updateByPrimaryKeySelective(LikeAndFavorites record);

    int updateByPrimaryKey(LikeAndFavorites record);

    /**
     * 通过用户主键和文章主键更新用户点赞信息
     * @return
     */
    int updateByUidAndArticleId(@Param("articleId")Integer articleId,@Param("uid")Integer uid,@Param("like") Boolean like);

    LikeAndFavorites selectUserIsLikeOrFavorites(@Param("uid")Integer uid, @Param("articleId")Integer articleId);

    /**
     * 用户文章点赞信息，存在就更新，不存在就插入
     * @param articleId
     * @param uid
     * @param like
     * @return
     */
    int isExistUpdateIsNotInsert(@Param("articleId")Integer articleId,@Param("uid") Integer uid,@Param("like") Boolean like);

    /**
     * 用户文章收藏信息，存在就更新，不存在就插入
     * @param articleId
     * @param uid
     * @param favorites
     * @return
     */
    int isExistUpdateIsNotInsertFavorites(@Param("articleId")Integer articleId,@Param("uid") Integer uid,@Param("favorites") Boolean favorites);
}